//
//  RNOLMyGiftCouponCell.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/24.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLMyGiftCouponCell.h"


@interface RNOLMyGiftCouponCell ()

@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *addRateLabel;

@property (weak, nonatomic) IBOutlet UILabel *limitConditionLabel;
@property (weak, nonatomic) IBOutlet UILabel *dueTimeLabel;

@property (weak, nonatomic) IBOutlet UIButton *immediateUseButton;

@end



@implementation RNOLMyGiftCouponCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.immediateUseButton.titleLabel.numberOfLines = 2;
    self.bgImageView.userInteractionEnabled = YES;
    [self.contentView insertSubview: self.bgImageView atIndex:0];
    [self.bgImageView setLayerShadow:KBlackColor offset:CGSizeMake(1, 1) radius:5];
}

- (void)setType:(RNOLGiftCertificationType)type{
    _type = type;
    if (type == RNOLGiftCertificationTypeAvaiable) {
        [self avaiableLayout];
    }else{
        [self expireOrUsedLayout];
    }
}

#pragma mark - 可用
- (void)avaiableLayout{
    self.bgImageView.image = [UIImage imageNamed:@"rnol_giftcoupon_bg_avable"];
    self.immediateUseButton.userInteractionEnabled = YES;
    self.nameLabel.textColor = KWhiteColor;
    self.addRateLabel.textColor = KWhiteColor;
    self.limitConditionLabel.textColor = KWhiteColor;
    self.dueTimeLabel.textColor = KWhiteColor;
    [self.immediateUseButton setTitleColor: KWhiteColor forState:UIControlStateNormal];
}

#pragma mark -  过期或者已使用
- (void)expireOrUsedLayout{
    self.bgImageView.image = [UIImage imageNamed:@"rnol_gift_bg_disable"];
    self.immediateUseButton.userInteractionEnabled = NO;
    self.nameLabel.textColor = kTextLightGrayColor;
    self.addRateLabel.textColor = kTextLightGrayColor;
    self.limitConditionLabel.textColor = kTextLightGrayColor;
    self.dueTimeLabel.textColor = kTextLightGrayColor;
    NSString *buttonTitle = self.type == RNOLGiftCertificationTypeAlreadyUsed? @"已使用":@"已过期";
    [self.immediateUseButton setTitle: buttonTitle forState: UIControlStateNormal];
    [self.immediateUseButton setTitleColor: kTextLightGrayColor forState:UIControlStateNormal];
}



- (IBAction)immediateUseAction:(UIButton *)sender {
    NSLog(@"使用优惠券");

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
